package com.qywx.controller;

import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.qywx.entity.ExportTagEntity;
import com.qywx.entity.ExportTagTemplateEntity;
import com.qywx.entity.TagEntity;
import com.qywx.entity.TagRuleEntity;
import com.qywx.service.TagRuleService;
import com.qywx.service.TagService;
import com.qywx.utils.EasyPoiExcelUtil;
import com.qywx.utils.R;
import com.qywx.utils.WebExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName TagController
 * @Description: TODO
 * @Author zwc
 * @Date 2020/3/9
 * @Version V1.0
 **/
@Api(value = "标签规则接口管理", tags = {"标签规则接口管理"})
@RestController
@RequestMapping("/tagRule")
public class TagRuleController {

    @Autowired
    TagRuleService tagRuleService;


    @PostMapping("/save")
    @ApiOperation(value = "新增标签规则", notes = "新增标签规则")
    public R save(@RequestBody TagRuleEntity tagEntity){
        return tagRuleService.saveTagRule(tagEntity);
    }


    @PostMapping("/updateTagRuleById")
    @ApiOperation(value = "修改标签规则根据id", notes = "修改标签规则根据id")
    public R updateTag(@RequestBody TagRuleEntity tagEntity){
        return tagRuleService.updateTagRule(tagEntity);
    }

    @GetMapping("/findTagRuleByTagId")
    @ApiOperation(value = "根据tagId查询标签规则列表", notes = "根据tagId查询标签规则列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tagId", required = true, value = "标签id", paramType = "query", dataType = "Long"),
            @ApiImplicitParam(name = "page", required = true, value = "当前页码", paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "size", required = true, value = "每页显示条数", paramType = "query", dataType = "int"),
    })
    public R findTagByName(@RequestParam("tagId") long tagId,@RequestParam("page") int page,@RequestParam("size") int size){
        return tagRuleService.findTagRuleByTagId(tagId,page,size);
    }
}
